﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DiskGallery
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btLogin_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid) return;
            if ((txtLogin.Text == "admin") && (txtPassword.Text == "1"))
            {
                Session["user"] = "admin";
               // (Assembly.GetEntryAssembly().CodeBase)
                
                string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).ToString();
                string file = directory.Substring(6) + "\\Log.txt";
                string strLogin = DateTime.Now + ": User " + Session["user"] + " is logged\r\n";
                using (StreamWriter outfile = File.AppendText(file))
                {
                    outfile.WriteLine(strLogin);
                }


                Response.Redirect("Default.aspx");
            }
            else
            {
                lbLoginError.Text = "Wrong Login or Password";
            }
        }

    }
}
